#include "ScnsOv2640.c.h"

#if defined(SCNS_OV2640_ENABLE)&&SCNS_OV2640_ENABLE==1

#include "ScnsIic.h"
#include "dcmi.h"

ScnsStatus scnsBspOv2640Write(ScnsOv2640Enum ov2N,const uint8*addr,uint8 addrLen,const uint8*data,uint8 dataLen)
{
#if defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1
    return scnsIicWriteTick(SCNS_IIC_SOFT_1,0X60,addr,addrLen,data,dataLen,128);
#else
    const uint16 ADDR=(addr[0]<<8)|addr[1];
    HAL_I2C_Mem_Write(&hi2c1,0X60,ADDR,2,data,dataLen,0XFFFFFF);
    return SCNS_STATUS_OK;
#endif
}

ScnsStatus scnsBspOv2640Read(ScnsOv2640Enum ov2N,const uint8*addr,uint8 addrLen,uint8*data,uint8 dataLen)
{
#if defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1
    return scnsIicReadTick(SCNS_IIC_SOFT_1,0X60,addr,addrLen,data,dataLen,128);
#else
    const uint16 ADDR=(addr[0]<<8)|addr[1];
    HAL_I2C_Mem_Read(&hi2c1,0X60,ADDR,2,data,dataLen,0XFFFFFF);
    return SCNS_STATUS_OK;
#endif
}

ScnsStatus scnsBspOv2640DmaStart(ScnsOv2640Enum ov2N,uint8*ptr,uint32 size)
{
    scnsCheckSTM32HALStatus(HAL_DCMI_Start_DMA(&hdcmi,DCMI_MODE_SNAPSHOT,(uint32_t)ptr,size/4));return SCNS_STATUS_OK;
}

#endif
